package com.wytec.xywzxw.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wytec.common.annotation.Log;
import com.wytec.common.core.controller.BaseController;
import com.wytec.common.core.domain.AjaxResult;
import com.wytec.common.enums.BusinessType;
import com.wytec.xywzxw.domain.XwVersion;
import com.wytec.xywzxw.service.IXwVersionService;
import com.wytec.common.utils.poi.ExcelUtil;
import com.wytec.common.core.page.TableDataInfo;

/**
 * 版本更新Controller
 * 
 * @author xywzxw
 * @date 2025-10-28
 */
@RestController
@RequestMapping("/xywzxw/version")
public class XwVersionController extends BaseController
{
    @Autowired
    private IXwVersionService xwVersionService;

    /**
     * 查询版本更新列表
     */
    @PreAuthorize("@ss.hasPermi('xywzxw:version:list')")
    @GetMapping("/list")
    public TableDataInfo list(XwVersion xwVersion)
    {
        startPage();
        List<XwVersion> list = xwVersionService.selectXwVersionList(xwVersion);
        return getDataTable(list);
    }

    /**
     * 导出版本更新列表
     */
    @PreAuthorize("@ss.hasPermi('xywzxw:version:export')")
    @Log(title = "版本更新", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XwVersion xwVersion)
    {
        List<XwVersion> list = xwVersionService.selectXwVersionList(xwVersion);
        ExcelUtil<XwVersion> util = new ExcelUtil<XwVersion>(XwVersion.class);
        util.exportExcel(response, list, "版本更新数据");
    }

    /**
     * 获取版本更新详细信息
     */
    @PreAuthorize("@ss.hasPermi('xywzxw:version:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(xwVersionService.selectXwVersionById(id));
    }

    /**
     * 新增版本更新
     */
    @PreAuthorize("@ss.hasPermi('xywzxw:version:add')")
    @Log(title = "版本更新", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XwVersion xwVersion)
    {
        return toAjax(xwVersionService.insertXwVersion(xwVersion));
    }

    /**
     * 修改版本更新
     */
    @PreAuthorize("@ss.hasPermi('xywzxw:version:edit')")
    @Log(title = "版本更新", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XwVersion xwVersion)
    {
        return toAjax(xwVersionService.updateXwVersion(xwVersion));
    }

    /**
     * 删除版本更新
     */
    @PreAuthorize("@ss.hasPermi('xywzxw:version:remove')")
    @Log(title = "版本更新", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xwVersionService.deleteXwVersionByIds(ids));
    }
}
